package com.he.domain.vo;


import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * @author He
 * @version 1.0
 * @Date 2023/9/21 18:09
 * @Desc 文章热门视图模型
 */
@Data
@Schema(description = "文章热门视图模型")
public class ArticleHotVO implements Comparable<ArticleHotVO> {
    /**
     * 文章id
     */
    @Schema(description = "文章id")
    private Integer id;

    /**
     * 文章缩略图
     */
    @Schema(description = "文章缩略图")
    private String articleCover;

    /**
     * 文章标题
     */
    @Schema(description = "文章标题")
    private String articleTitle;

    /**
     * 文章浏览量
     */
    @Schema(description = "文章浏览量")
    private Integer articleViews;

    /**
     * 文章分类
     */
    @Schema(description = "文章分类")
    private CategoryOptionVO category;

    /**
     * 发表时间
     */
    @Schema(description = "发表时间")
    private LocalDateTime createTime;

    /**
     * 按浏览量降序
     */
    @Override
    public int compareTo(@NotNull ArticleHotVO o) {
        return o.articleViews - this.articleViews;
    }
}
